char a[5000];b[2001];main(n,l,c,w){for(;~scanf("%d\n",&c);)for(;~scanf("%d ",&c);printf("%d\n",*b))for(gets(a),w=l=0;c--;l+=2){if(a[l]=='+')b[--w-1]+=b[w];else if(a[l]=='-')b[--w-1]-=b[w];else if(a[l]=='*')b[--w-1]*=b[w];else b[w++]=a[l]-48;}}
